﻿using System.Text;
using msilgc.cbuilder.CSyntaxTree;

namespace msilgc.CSyntaxTree {
    internal class ArrayLengthStatement : ICStatementWithAssignment {
        public IVariable Target { get; set; }
        public IVariable SourceArray { get; set; }
        public bool OnStack { get; set; }

        public ArrayLengthStatement(IVariable target, IVariable sourceArray) {
            OnStack = true;
            Target = target;
            SourceArray = sourceArray;
        }

        public void Emit(StringBuilder builder) {
            Target.Emit(builder);
            builder.Append(" = ");
            SourceArray.Emit(builder);
            builder.AppendLine(".array_length;");
        }
    }
}
